#include "./include/common.h"
#include "./include/ArgParser.h"
#include "./include/PointCloudReader.h"
#include "./include/Evaluator.h"

#include "./include/extractShapes.h"

using namespace std;

evaluation::ArgParser args;
evaluation::PointCloudReader reader;
evaluation::Evaluator eval;
PointCloud::Ptr cloud(new PointCloud);

int main(int argc, char** argv)
{
	if(args.parseArg(argc, argv) == -1)
		args.printHelp();
	 
	string input = args.getArgs().input_folder;
	eval.setArgs(args.getArgs());
	//std::string output_filename = input + "/evaluation_precision.txt";
	//std::ofstream result_output(output_filename.c_str());
	//result_output << "点云文件\t精度\t平均厚度\t最大厚度" << std::endl;
	// reader.readFileList(input);

	// for(auto f : reader.getFileList())
	// {
	// 	if( reader.readCloud(f, cloud) != -1)
	// 	{
	// 		eval.addPointCloud(cloud);
	// 		// result_output << getFileName(f) << "\t" << cur_sd << "\t" << mean_dis << "\t" << in << std::endl;
	// 		// result_output << cur_sd*100 << std::endl;
	// 		// std::cout.width(10);
	// 		// std::cout.setf(std::ios::left);
	// 		// std::cout << cur_sd*100;
	// 		// std::cout << " " << mean_dis*100 << std::endl;
	// 	}
	// }

	ExtractShapes::RectangleCircleExtractor example(input.c_str(), 13, 500);
    example.extractAndEval(eval);

	// result_output << "总平均厚度 = " << mean_dis_sum / plains_count << std::endl
	//				 << "平均精度 = " << standard_deviation_sum / plains_count << std::endl;
	cout.width(10);
	cout.setf(ios::left);
	cout << "平均厚度 = " << eval.getMean() << "cm" << endl
	     << "平均精度 = " << eval.getStandardDeviation() << "cm" << endl;
	return 0;
}
